﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Data;
using System.Xml;
using OgilvyOne.Utility;

namespace OgilvyOne.BLL
{
    /// <summary>
    /// 列表标签,循环替换标签内容
    /// <cms:labellist value="方法名" labelname="标签定义名" rows="行数"></cms:labellist>
    /// </summary>
    class LabelListLabel : LabelCommonLabel
    {
        private ListLabel ll;
        public LabelListLabel(CommonModel model)
            : base(model)
        {
            ll = new ListLabel(model);
        }

        private int rows;
        public int Rows
        {
            get { return rows; }
            set { rows = value; }
        }

        public override string GetLabelLabelHtml()
        {
            ll.LabelStr = LabelStr;
            ll.Rows = rows;
            ll.MethodName = MethodName;
            XmlDocument doc = GetLabelValueXmlDocument(GetLabelValue());

            ll.LabelNodeStr = doc.SelectSingleNode("//list").Value;

            if (doc.SelectSingleNode("//method") != null)
            {
                ll.MethodName = doc.SelectSingleNode("//method").Value;
            }
            if (doc.SelectSingleNode("//rows") != null)
            {
                ll.Rows = int.Parse(doc.SelectSingleNode("//rows").Value);
            }

            return ll.GetLabelHtml();
        }
    }
}
